<?php
class new_list extends common
{
    function index()
    {
        if (!empty($_GET['search'])) {
            $search_key = trim($_GET['search']);
        }

        if (!empty($_POST['search'])) {
            $_GET['search'] = trim($_POST['search']);
            $search_key = trim($_POST['search']);
        }
        $where_a = '';
        if ($search_key) {
            $where_a .= ' and title like :search_key';
        }
        $conn_mysql = _mysqllogon('Mysql_102');
        mysql_set_charset("gbk");
        mysql_query("SET character_set_client=binary");

        $sql_a = "select id,title,type,status,
                    date_format(update_time, '%Y-%m-%d %H:%i:%s') as update_time_f
                     from spread_news where id>0 " . $where_a . " order by type asc,update_time desc";
        $stmt_a = _mysqlparse($conn_mysql, $sql_a);
        if ($search_key) {
            _mysqlbindbyname($stmt_a, ":search_key", trim("%{$search_key}%"));
        }
        $mysqlerror = _mysqlexecute($stmt_a);
        if ($mysqlerror) {
            die(json_encode(array(
                'error' => 5001,
                'message' => 'system error,select news failed'
            )));
        }
        $this->data = array();
        while ($a_row = mysql_fetch_assoc($stmt_a)) {
            $this->data[] = $a_row;
        }

        include APP_PATH . "/view/list_new.html";
    }
}

?>